[1] 8629 9627 4598 1031 4847 5189 9297 7081 5766 6406 5743 2069 5972 7935 4580
[16] 4154 7393 3193 5161 5851 1843 3540 1268 7823 4875 1574 4508
HumanAf$ContextEffectf <-dplyr::recode(HumanAf$BuildingCategory_Building,
Residential = -0.5, Public= 0.5,
.default = NaN)
HumanAf$AgentPresence <-dplyr::recode(HumanAf$AvatarPresenceCategory_Building,
Omitted = -0.5, Present= 0.5,
.default = NaN)
HumanAf$Agent_Action_level <-dplyr::recode(HumanAf$Agent_Action_level,
Passive = -0.5, Active= 0.5,
.default = NaN)
HumanAf$ContextEffectf <-factor(HumanAf$ContextEffectf,levels= c(-0.5, 0.5),
labels=c('Residential', 'Public'))
HumanAf$AgentPresencef <-factor(HumanAf$AgentPresence,
levels= c(-0.5, 0.5),
labels=c('Omitted', 'Displayed'))
HumanAf$Agent_Action_levelf <-factor(HumanAf$Agent_Action_level,
levels= c(-0.5, 0.5),
labels=c('Passive', 'Active'))MainVariables <- subset(HumanAf, select = c(AbsolutError_Building, RT_Building))
summary(MainVariables) AbsolutError_Building RT_Building
Min. : 0.00676 Min. : 0.8616
1st Qu.: 13.31804 1st Qu.: 4.5096
Median : 34.42989 Median : 8.1352
Mean : 48.03731 Mean : 9.7420
3rd Qu.: 70.30188 3rd Qu.:13.7155
Max. :179.97165 Max. :29.7118
NA's :8 NA's :8
summary(HumanAf$AgentPresence) Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
-0.500000 -0.500000 -0.500000 -0.000823 0.500000 0.500000 8
df = HumanAf[complete.cases(HumanAf),]
ggplot(df, aes(x=ContextEffectf, y=AbsolutError_Building, fill=AgentPresencef)) +
geom_boxplot(notch=TRUE,
notchwidth = 0.8,
outlier.colour="red",
outlier.fill="red",
outlier.size=0.5)ggplot(df, aes(x=ContextEffectf, y=RT_Building, fill=AgentPresencef)) +
geom_boxplot(notch=TRUE,
notchwidth = 0.8,
outlier.colour="red",
outlier.fill="red",
outlier.size=0.5)library(dplyr)
TwoFactorTable <- HumanAf %>%
group_by(ContextEffectf, AgentPresencef)%>%
summarise(AccuracyMean = mean(AbsolutError_Building, na.rm = TRUE),
n=n(),
AccuracyStandardDev = sd(AbsolutError_Building, na.rm = TRUE),
RT_BuildingMean = mean(RT_Building, na.rm = TRUE),
RTStandardDev = sd(RT_Building, na.rm = TRUE))`summarise()` has grouped output by 'ContextEffectf'. You can override using
the `.groups` argument.
library(tidyr)
Attaching package: 'tidyr'
The following objects are masked from 'package:Matrix':
expand, pack, unpack
The following object is masked from 'package:dlookr':
extract
TwoFactorTableUnite <- TwoFactorTable %>%
unite("TwoFactor", ContextEffectf:AgentPresencef, sep= " ", remove = F)
TwoFactorTableUnite <- TwoFactorTableUnite %>%
mutate( AccuracyStandardError=AccuracyStandardDev/sqrt(n)) %>%
mutate( AccuracyStandardIC=AccuracyStandardDev * qt((1-0.05)/2 + .5, n-1)) %>%
mutate( RTStandardError=RTStandardDev/sqrt(n)) Warning: Ignoring unknown aesthetics: linetype
Warning: Ignoring unknown aesthetics: linetype
library(dplyr)
ThreeFactorTable <- HumanAf %>%
group_by(ContextEffectf, AgentPresencef, Agent_Action_levelf)%>%
summarise(AccuracyMean = mean(AbsolutError_Building, na.rm = TRUE),
n=n(),
AccuracyStandardDev = sd(AbsolutError_Building, na.rm = TRUE),
RT_BuildingMean = mean(RT_Building, na.rm = TRUE),
RTStandardDev = sd(RT_Building, na.rm = TRUE))`summarise()` has grouped output by 'ContextEffectf', 'AgentPresencef'. You can
override using the `.groups` argument.
library(tidyr)
ThreeFactorTableUnite <- ThreeFactorTable %>%
unite("ThreeFactor", ContextEffectf:AgentPresencef, sep= " ", remove = F)
ThreeFactorTableUnite <- ThreeFactorTableUnite %>%
mutate( AccuracyStandardError=AccuracyStandardDev/sqrt(n)) %>%
mutate( AccuracyStandardIC=AccuracyStandardDev * qt((1-0.05)/2 + .5, n-1)) %>%
mutate( RTStandardError=RTStandardDev/sqrt(n))
ThreeFactorTableUnite <-ThreeFactorTableUnite %>% drop_na()Warning: Ignoring unknown aesthetics: linetype
Warning: Ignoring unknown aesthetics: linetype
df$AbsolutError_BuildingR <- round(df$AbsolutError_Building, digits = 3)
qqp(df$AbsolutError_BuildingR, "norm")[1] 1283 318
n_distinct(df$ID)[1] 17
# Set up contrast to sum zero A.K.A compare each level equally
contrasts(df$ContextEffectf) <- "contr.sum"
contrasts(df$AgentPresencef) <- "contr.sum"
contrasts(df$Agent_Action_levelf) <- "contr.sum"interceptOnly <-gls(AbsolutError_Building ~ 1, data = df,
method = "ML")
IDrandomInterceptOnly <-lme(AbsolutError_Building ~ 1, data = df,
random =~1|ID,
method = "ML")
StartlocationsrandomIntercept <-update(IDrandomInterceptOnly, .~.,
random=~1|ID/PointingTaskStartingLocations_Building,
method= "ML")Including Id and starting position as random effects significantly improves the fit of the model
I am adding one main factor at a time
AgentActive <-update(StartlocationsrandomIntercept, .~. + Agent_Action_levelf)
summary(AgentActive)Linear mixed-effects model fit by maximum likelihood
Data: df
AIC BIC logLik
39223.21 39254.43 -19606.61
Random effects:
Formula: ~1 | ID
(Intercept)
StdDev: 12.44818
Formula: ~1 | PointingTaskStartingLocations_Building %in% ID
(Intercept) Residual
StdDev: 13.8596 40.00401
Fixed effects: AbsolutError_Building ~ Agent_Action_levelf
Value Std.Error DF t-value p-value
(Intercept) 47.89518 3.1537650 3326 15.186666 0
Agent_Action_levelf1 2.87219 0.6743963 3326 4.258904 0
Correlation:
(Intr)
Agent_Action_levelf1 -0.012
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-2.0857630 -0.6696041 -0.2240354 0.4811421 3.4992164
Number of Observations: 3803
Number of Groups:
ID
17
PointingTaskStartingLocations_Building %in% ID
476
Anova(AgentActive, test.statistic="F", type=3)Analysis of Deviance Table (Type III tests)
Response: AbsolutError_Building
Chisq Df Pr(>Chisq)
(Intercept) 230.756 1 < 2.2e-16 ***
Agent_Action_levelf 18.148 1 2.044e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
MeaningfulContext <-update(AgentActive, .~. + ContextEffectf)
summary(MeaningfulContext)Linear mixed-effects model fit by maximum likelihood
Data: df
AIC BIC logLik
39215.44 39252.9 -19601.72
Random effects:
Formula: ~1 | ID
(Intercept)
StdDev: 12.44457
Formula: ~1 | PointingTaskStartingLocations_Building %in% ID
(Intercept) Residual
StdDev: 13.98064 39.92712
Fixed effects: AbsolutError_Building ~ Agent_Action_levelf + ContextEffectf
Value Std.Error DF t-value p-value
(Intercept) 47.89901 3.1542071 3325 15.185754 0.0000
Agent_Action_levelf1 2.80568 0.6737912 3325 4.164014 0.0000
ContextEffectf1 2.10977 0.6740993 3325 3.129760 0.0018
Correlation:
(Intr) Ag_A_1
Agent_Action_levelf1 -0.012
ContextEffectf1 0.000 -0.031
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-2.0354326 -0.6646727 -0.2213412 0.4817722 3.5492386
Number of Observations: 3803
Number of Groups:
ID
17
PointingTaskStartingLocations_Building %in% ID
476
Anova(MeaningfulContext, test.statistic="F", type=3)Analysis of Deviance Table (Type III tests)
Response: AbsolutError_Building
Chisq Df Pr(>Chisq)
(Intercept) 230.7892 1 < 2.2e-16 ***
Agent_Action_levelf 17.3527 1 3.105e-05 ***
ContextEffectf 9.8031 1 0.001742 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TwofactorInteraction <-update(StartlocationsrandomIntercept, .~. + ContextEffectf*Agent_Action_levelf)
summary(TwofactorInteraction)Linear mixed-effects model fit by maximum likelihood
Data: df
AIC BIC logLik
39212.75 39256.46 -19599.38
Random effects:
Formula: ~1 | ID
(Intercept)
StdDev: 12.42152
Formula: ~1 | PointingTaskStartingLocations_Building %in% ID
(Intercept) Residual
StdDev: 13.93913 39.90874
Fixed effects: AbsolutError_Building ~ ContextEffectf + Agent_Action_levelf + ContextEffectf:Agent_Action_levelf
Value Std.Error DF t-value p-value
(Intercept) 47.85124 3.1488977 3324 15.196188 0.0000
ContextEffectf1 2.02550 0.6749036 3324 3.001174 0.0027
Agent_Action_levelf1 2.80973 0.6735061 3324 4.171793 0.0000
ContextEffectf1:Agent_Action_levelf1 1.46554 0.6768591 3324 2.165205 0.0304
Correlation:
(Intr) CntxE1 Ag_A_1
ContextEffectf1 0.001
Agent_Action_levelf1 -0.012 -0.031
ContextEffectf1:Agent_Action_levelf1 -0.007 -0.057 0.003
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-2.0133937 -0.6586408 -0.2297155 0.4871098 3.5268823
Number of Observations: 3803
Number of Groups:
ID
17
PointingTaskStartingLocations_Building %in% ID
476
Anova(TwofactorInteraction)Analysis of Deviance Table (Type II tests)
Response: AbsolutError_Building
Chisq Df Pr(>Chisq)
ContextEffectf 9.8047 1 0.001741 **
Agent_Action_levelf 17.3754 1 3.068e-05 ***
ContextEffectf:Agent_Action_levelf 4.6930 1 0.030285 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Pairwise<- emmeans(TwofactorInteraction, pairwise ~ ContextEffectf*Agent_Action_levelf)Warning: contrasts dropped from factor ContextEffectf
Warning: contrasts dropped from factor Agent_Action_levelf
Pairwise$emmeans
ContextEffectf Agent_Action_levelf emmean SE df lower.CL upper.CL
Residential Passive 54.2 3.34 16 47.1 61.2
Public Passive 47.2 3.35 16 40.1 54.3
Residential Active 45.6 3.38 16 38.4 52.8
Public Active 44.5 3.36 16 37.3 51.6
Degrees-of-freedom method: containment
Confidence level used: 0.95
$contrasts
contrast estimate SE df t.ratio p.value
Residential Passive - Public Passive 6.98 1.86 3324 3.761 0.0010
Residential Passive - Residential Active 8.55 1.91 3324 4.472 <.0001
Residential Passive - Public Active 9.67 1.88 3324 5.152 <.0001
Public Passive - Residential Active 1.57 1.94 3324 0.810 0.8498
Public Passive - Public Active 2.69 1.91 3324 1.410 0.4934
Residential Active - Public Active 1.12 1.97 3324 0.570 0.9411
Degrees-of-freedom method: containment
P value adjustment: tukey method for comparing a family of 4 estimates
plot(Pairwise[[2]], CIs = TRUE)
### Interaction plus presence
AgentPresence <-update(TwofactorInteraction, .~. + AgentPresencef)
summary(AgentPresence)Linear mixed-effects model fit by maximum likelihood
Data: df
AIC BIC logLik
39214.41 39264.36 -19599.2
Random effects:
Formula: ~1 | ID
(Intercept)
StdDev: 12.42074
Formula: ~1 | PointingTaskStartingLocations_Building %in% ID
(Intercept) Residual
StdDev: 13.943 39.90611
Fixed effects: AbsolutError_Building ~ ContextEffectf + Agent_Action_levelf + AgentPresencef + ContextEffectf:Agent_Action_levelf
Value Std.Error DF t-value p-value
(Intercept) 47.85089 3.1491576 3323 15.194823 0.0000
ContextEffectf1 2.03191 0.6750415 3323 3.010048 0.0026
Agent_Action_levelf1 2.80812 0.6735646 3323 4.169040 0.0000
AgentPresencef1 0.39558 0.6729468 3323 0.587831 0.5567
ContextEffectf1:Agent_Action_levelf1 1.46725 0.6769202 3323 2.167540 0.0303
Correlation:
(Intr) CntxE1 Ag_A_1 AgntP1
ContextEffectf1 0.001
Agent_Action_levelf1 -0.012 -0.031
AgentPresencef1 0.000 0.016 -0.004
ContextEffectf1:Agent_Action_levelf1 -0.007 -0.057 0.003 0.004
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-2.0211553 -0.6600032 -0.2313468 0.4854995 3.5160738
Number of Observations: 3803
Number of Groups:
ID
17
PointingTaskStartingLocations_Building %in% ID
476
Anova(AgentPresence)Analysis of Deviance Table (Type II tests)
Response: AbsolutError_Building
Chisq Df Pr(>Chisq)
ContextEffectf 9.8628 1 0.001687 **
Agent_Action_levelf 17.3573 1 3.097e-05 ***
AgentPresencef 0.3460 1 0.556386
ContextEffectf:Agent_Action_levelf 4.7044 1 0.030085 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AllInteractions <-update(StartlocationsrandomIntercept, .~. + ContextEffectf*Agent_Action_levelf*AgentPresencef)
summary(AllInteractions)Linear mixed-effects model fit by maximum likelihood
Data: df
AIC BIC logLik
39219.49 39288.17 -19598.75
Random effects:
Formula: ~1 | ID
(Intercept)
StdDev: 12.41768
Formula: ~1 | PointingTaskStartingLocations_Building %in% ID
(Intercept) Residual
StdDev: 13.97801 39.89464
Fixed effects: AbsolutError_Building ~ ContextEffectf + Agent_Action_levelf + AgentPresencef + ContextEffectf:Agent_Action_levelf + ContextEffectf:AgentPresencef + Agent_Action_levelf:AgentPresencef + ContextEffectf:Agent_Action_levelf:AgentPresencef
Value Std.Error DF
(Intercept) 47.86050 3.1499994 3320
ContextEffectf1 2.03156 0.6752019 3320
Agent_Action_levelf1 2.80414 0.6737584 3320
AgentPresencef1 0.41528 0.6745097 3320
ContextEffectf1:Agent_Action_levelf1 1.46168 0.6771464 3320
ContextEffectf1:AgentPresencef1 0.55511 0.6744019 3320
Agent_Action_levelf1:AgentPresencef1 -0.09960 0.6734941 3320
ContextEffectf1:Agent_Action_levelf1:AgentPresencef1 -0.34613 0.6729880 3320
t-value p-value
(Intercept) 15.193812 0.0000
ContextEffectf1 3.008819 0.0026
Agent_Action_levelf1 4.161942 0.0000
AgentPresencef1 0.615674 0.5382
ContextEffectf1:Agent_Action_levelf1 2.158591 0.0310
ContextEffectf1:AgentPresencef1 0.823109 0.4105
Agent_Action_levelf1:AgentPresencef1 -0.147891 0.8824
ContextEffectf1:Agent_Action_levelf1:AgentPresencef1 -0.514325 0.6071
Correlation:
(Intr) CntxE1 Ag_A_1
ContextEffectf1 0.001
Agent_Action_levelf1 -0.012 -0.031
AgentPresencef1 0.000 0.016 -0.005
ContextEffectf1:Agent_Action_levelf1 -0.007 -0.057 0.003
ContextEffectf1:AgentPresencef1 0.003 -0.004 0.000
Agent_Action_levelf1:AgentPresencef1 -0.001 0.000 0.005
ContextEffectf1:Agent_Action_levelf1:AgentPresencef1 0.000 -0.003 0.011
AgntP1 CnE1:A_A_1 CE1:AP
ContextEffectf1
Agent_Action_levelf1
AgentPresencef1
ContextEffectf1:Agent_Action_levelf1 0.004
ContextEffectf1:AgentPresencef1 0.010 -0.004
Agent_Action_levelf1:AgentPresencef1 -0.057 0.013 -0.028
ContextEffectf1:Agent_Action_levelf1:AgentPresencef1 -0.030 0.006 -0.056
A_A_1:
ContextEffectf1
Agent_Action_levelf1
AgentPresencef1
ContextEffectf1:Agent_Action_levelf1
ContextEffectf1:AgentPresencef1
Agent_Action_levelf1:AgentPresencef1
ContextEffectf1:Agent_Action_levelf1:AgentPresencef1 0.005
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-2.0176639 -0.6583698 -0.2275608 0.4864835 3.5361017
Number of Observations: 3803
Number of Groups:
ID
17
PointingTaskStartingLocations_Building %in% ID
476
Anova(AllInteractions)Analysis of Deviance Table (Type II tests)
Response: AbsolutError_Building
Chisq Df Pr(>Chisq)
ContextEffectf 9.8763 1 0.001674 **
Agent_Action_levelf 17.3669 1 3.081e-05 ***
AgentPresencef 0.3465 1 0.556122
ContextEffectf:Agent_Action_levelf 4.6823 1 0.030474 *
ContextEffectf:AgentPresencef 0.6340 1 0.425877
Agent_Action_levelf:AgentPresencef 0.0212 1 0.884364
ContextEffectf:Agent_Action_levelf:AgentPresencef 0.2651 1 0.606646
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(interceptOnly, IDrandomInterceptOnly, StartlocationsrandomIntercept,
AgentActive, MeaningfulContext, TwofactorInteraction, AgentPresence) Model df AIC BIC logLik Test
interceptOnly 1 2 39616.63 39629.12 -19806.31
IDrandomInterceptOnly 2 3 39345.03 39363.76 -19669.51 1 vs 2
StartlocationsrandomIntercept 3 4 39239.31 39264.29 -19615.66 2 vs 3
AgentActive 4 5 39223.21 39254.43 -19606.60 3 vs 4
MeaningfulContext 5 6 39215.44 39252.90 -19601.72 4 vs 5
TwofactorInteraction 6 7 39212.75 39256.46 -19599.38 5 vs 6
AgentPresence 7 8 39214.41 39264.36 -19599.20 6 vs 7
L.Ratio p-value
interceptOnly
IDrandomInterceptOnly 273.60305 <.0001
StartlocationsrandomIntercept 107.71327 <.0001
AgentActive 18.10324 <.0001
MeaningfulContext 9.76860 0.0018
TwofactorInteraction 4.68893 0.0304
AgentPresence 0.34596 0.5564
plot(TwofactorInteraction, which = 1)plot(MeaningfulContext, which = 1)
### General linear models using a log link link function on an assumed
gaussian distribution
GHQ <- glmer(AbsolutError_Building ~ ContextEffectf*AgentPresencef + (1|ID), data = HumanAf,family=gaussian(link = "log"), nAGQ = 25) Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?
summary(GHQ)Generalized linear mixed model fit by maximum likelihood (Adaptive
Gauss-Hermite Quadrature, nAGQ = 25) [glmerMod]
Family: gaussian ( log )
Formula: AbsolutError_Building ~ ContextEffectf * AgentPresencef + (1 |
ID)
Data: HumanAf
AIC BIC logLik deviance df.resid
7608606 7608644 -3804297 7608594 4245
Scaled residuals:
Min 1Q Median 3Q Max
-1.6833 -0.7199 -0.2728 0.4820 3.3811
Random effects:
Groups Name Variance Std.Dev.
ID (Intercept) 128.8 11.35
Residual 1789.8 42.31
Number of obs: 4251, groups: ID, 19
Fixed effects:
Estimate Std. Error t value
(Intercept) 3.8702587 0.0615479 62.882
ContextEffectfPublic -0.0634144 0.0008766 -72.341
AgentPresencefDisplayed 0.0035992 0.0008493 4.238
ContextEffectfPublic:AgentPresencefDisplayed -0.0163270 0.0012462 -13.102
Pr(>|z|)
(Intercept) < 2e-16 ***
ContextEffectfPublic < 2e-16 ***
AgentPresencefDisplayed 2.26e-05 ***
ContextEffectfPublic:AgentPresencefDisplayed < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Correlation of Fixed Effects:
(Intr) CntxEP AgntPD
CntxtEffctP -0.007
AgntPrsncfD -0.007 0.491
CntxtEP:APD 0.005 -0.705 -0.683
optimizer (Nelder_Mead) convergence code: 0 (OK)
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?
Anova(GHQ)Analysis of Deviance Table (Type II Wald chisquare tests)
Response: AbsolutError_Building
Chisq Df Pr(>Chisq)
ContextEffectf 13247.445 1 < 2.2e-16 ***
AgentPresencef 41.748 1 1.038e-10 ***
ContextEffectf:AgentPresencef 171.656 1 < 2.2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(GHQ)Analysis of Variance Table
npar Sum Sq Mean Sq F value
ContextEffectf 1 13283.6 13283.6 7.4219
AgentPresencef 1 41.6 41.6 0.0233
ContextEffectf:AgentPresencef 1 172.0 172.0 0.0961
emmeans(GHQ, pairwise ~ ContextEffectf:AgentPresencef, type = "response")$emmeans
ContextEffectf AgentPresencef response SE df asymp.LCL asymp.UCL
Residential Omitted 48.0 2.95 Inf 42.5 54.1
Public Omitted 45.0 2.77 Inf 39.9 50.8
Residential Displayed 48.1 2.96 Inf 42.7 54.3
Public Displayed 44.4 2.74 Inf 39.4 50.1
Confidence level used: 0.95
Intervals are back-transformed from the log scale
$contrasts
contrast ratio SE df null z.ratio
Residential Omitted / Public Omitted 1.0655 0.0009340 Inf 1 72.341
Residential Omitted / Residential Displayed 0.9964 0.0008462 Inf 1 -4.238
Residential Omitted / Public Displayed 1.0791 0.0009567 Inf 1 85.886
Public Omitted / Residential Displayed 0.9352 0.0008145 Inf 1 -76.942
Public Omitted / Public Displayed 1.0128 0.0009213 Inf 1 13.991
Residential Displayed / Public Displayed 1.0830 0.0009566 Inf 1 90.276
p.value
<.0001
0.0001
<.0001
<.0001
<.0001
<.0001
P value adjustment: tukey method for comparing a family of 4 estimates
Tests are performed on the log scale
plot(fitted(GHQ), residuals(GHQ), xlab = "Fitted Values", ylab = "Residuals")
abline(h = 0, lty = 2)
lines(smooth.spline(fitted(GHQ), residuals(GHQ)))
### Manually log transforming the absolut error
interceptOnly <-gls(log(AbsolutError_Building) ~ 1, data = df,
method = "ML")
IDrandomInterceptOnly <-lme(log(AbsolutError_Building) ~ 1, data = df,
random =~1|ID,
method = "ML")
StartlocationsrandomIntercept <-update(IDrandomInterceptOnly, .~.,
random=~1|ID/PointingTaskStartingLocations_Building,
method= "ML")
MeaningfulContext <-update(StartlocationsrandomIntercept, .~. + ContextEffectf)
AgentActive <-update(StartlocationsrandomIntercept, .~. + Agent_Action_levelf)
TwofactorInteraction <-update(StartlocationsrandomIntercept, .~. + ContextEffectf*Agent_Action_levelf)
summary(TwofactorInteraction)Linear mixed-effects model fit by maximum likelihood
Data: df
AIC BIC logLik
12983.92 13027.63 -6484.962
Random effects:
Formula: ~1 | ID
(Intercept)
StdDev: 0.3522174
Formula: ~1 | PointingTaskStartingLocations_Building %in% ID
(Intercept) Residual
StdDev: 0.3469856 1.28678
Fixed effects: log(AbsolutError_Building) ~ ContextEffectf + Agent_Action_levelf + ContextEffectf:Agent_Action_levelf
Value Std.Error DF t-value p-value
(Intercept) 3.250745 0.08942177 3324 36.35295 0.0000
ContextEffectf1 0.067788 0.02153726 3324 3.14746 0.0017
Agent_Action_levelf1 0.056166 0.02150608 3324 2.61161 0.0091
ContextEffectf1:Agent_Action_levelf1 0.054977 0.02159255 3324 2.54609 0.0109
Correlation:
(Intr) CntxE1 Ag_A_1
ContextEffectf1 0.001
Agent_Action_levelf1 -0.014 -0.032
ContextEffectf1:Agent_Action_levelf1 -0.008 -0.057 0.003
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-6.0999775 -0.4666124 0.1969789 0.6806818 2.0367120
Number of Observations: 3803
Number of Groups:
ID
17
PointingTaskStartingLocations_Building %in% ID
476
Anova(TwofactorInteraction)Analysis of Deviance Table (Type II tests)
Response: log(AbsolutError_Building)
Chisq Df Pr(>Chisq)
ContextEffectf 10.8884 1 0.0009677 ***
Agent_Action_levelf 6.7910 1 0.0091617 **
ContextEffectf:Agent_Action_levelf 6.4894 1 0.0108520 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AgentPresence <-update(TwofactorInteraction, .~. + AgentPresencef)
summary(AgentPresence)Linear mixed-effects model fit by maximum likelihood
Data: df
AIC BIC logLik
12985.85 13035.79 -6484.923
Random effects:
Formula: ~1 | ID
(Intercept)
StdDev: 0.352233
Formula: ~1 | PointingTaskStartingLocations_Building %in% ID
(Intercept) Residual
StdDev: 0.3469354 1.286774
Fixed effects: log(AbsolutError_Building) ~ ContextEffectf + Agent_Action_levelf + AgentPresencef + ContextEffectf:Agent_Action_levelf
Value Std.Error DF t-value p-value
(Intercept) 3.250750 0.08943672 3323 36.34693 0.0000
ContextEffectf1 0.067691 0.02154257 3323 3.14222 0.0017
Agent_Action_levelf1 0.056191 0.02150891 3323 2.61245 0.0090
AgentPresencef1 -0.006017 0.02148117 3323 -0.28011 0.7794
ContextEffectf1:Agent_Action_levelf1 0.054959 0.02159528 3323 2.54494 0.0110
Correlation:
(Intr) CntxE1 Ag_A_1 AgntP1
ContextEffectf1 0.001
Agent_Action_levelf1 -0.014 -0.032
AgentPresencef1 0.000 0.016 -0.004
ContextEffectf1:Agent_Action_levelf1 -0.008 -0.057 0.003 0.003
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-6.0949245 -0.4669406 0.1980211 0.6795852 2.0323011
Number of Observations: 3803
Number of Groups:
ID
17
PointingTaskStartingLocations_Building %in% ID
476
Anova(AgentPresence)Analysis of Deviance Table (Type II tests)
Response: log(AbsolutError_Building)
Chisq Df Pr(>Chisq)
ContextEffectf 10.8551 1 0.0009852 ***
Agent_Action_levelf 6.7974 1 0.0091292 **
AgentPresencef 0.0786 1 0.7792505
ContextEffectf:Agent_Action_levelf 6.4852 1 0.0108773 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Pairwise<- emmeans(TwofactorInteraction, pairwise ~ ContextEffectf*Agent_Action_levelf, type='response')Warning: contrasts dropped from factor ContextEffectf
Warning: contrasts dropped from factor Agent_Action_levelf
Pairwise $emmeans
ContextEffectf Agent_Action_levelf response SE df lower.CL upper.CL
Residential Passive 30.9 2.97 16 25.2 37.8
Public Passive 24.1 2.33 16 19.7 29.6
Residential Active 24.7 2.42 16 20.1 30.4
Public Active 24.1 2.34 16 19.6 29.6
Degrees-of-freedom method: containment
Confidence level used: 0.95
Intervals are back-transformed from the log scale
$contrasts
contrast ratio SE df null t.ratio
Residential Passive / Public Passive 1.278 0.0757 3324 1 4.145
Residential Passive / Residential Active 1.249 0.0762 3324 1 3.642
Residential Passive / Public Active 1.281 0.0768 3324 1 4.138
Public Passive / Residential Active 0.977 0.0604 3324 1 -0.376
Public Passive / Public Active 1.002 0.0610 3324 1 0.039
Residential Active / Public Active 1.026 0.0643 3324 1 0.409
p.value
0.0002
0.0016
0.0002
0.9819
1.0000
0.9770
Degrees-of-freedom method: containment
P value adjustment: tukey method for comparing a family of 4 estimates
Tests are performed on the log scale
plot(Pairwise[[2]])anova(interceptOnly, IDrandomInterceptOnly, StartlocationsrandomIntercept,
MeaningfulContext, TwofactorInteraction ) Model df AIC BIC logLik Test
interceptOnly 1 2 13260.20 13272.69 -6628.101
IDrandomInterceptOnly 2 3 13046.39 13065.12 -6520.193 1 vs 2
StartlocationsrandomIntercept 3 4 13002.56 13027.54 -6497.281 2 vs 3
MeaningfulContext 4 5 12993.18 13024.40 -6491.590 3 vs 4
TwofactorInteraction 5 7 12983.92 13027.63 -6484.962 4 vs 5
L.Ratio p-value
interceptOnly
IDrandomInterceptOnly 215.81489 <.0001
StartlocationsrandomIntercept 45.82481 <.0001
MeaningfulContext 11.38201 0.0007
TwofactorInteraction 13.25554 0.0013
plot(TwofactorInteraction, which = 1)df = HumanAf[complete.cases(HumanAf),]
df$RTr <- round(df$RT_Building, digits = 3)
qqp(df$RT_Building, "norm")[1] 1132 1277
qqp(df$RT_Building, "lnorm")[1] 1132 1277
interceptOnlyt <-gls(log(RTr) ~ 1, data = df,
method = "ML")
IDrandomInterceptOnlyt <-lme(log(RTr) ~ 1, data = df,
random =~1|ID,
method = "ML")
StartlocationsrandomInterceptt <-lme(log(RTr) ~ 1, data = df,
random=~1|ID|PointingTaskStartingLocations_Building,
method= "ML")
MeaningfulContext <-update(StartlocationsrandomInterceptt, .~. + ContextEffectf)
AgentActive <-update(StartlocationsrandomIntercept, .~. + Agent_Action_levelf)
TwofactorInteraction <-update(StartlocationsrandomIntercept, .~. + ContextEffectf*Agent_Action_levelf)
summary(TwofactorInteraction)Linear mixed-effects model fit by maximum likelihood
Data: df
AIC BIC logLik
12983.92 13027.63 -6484.962
Random effects:
Formula: ~1 | ID
(Intercept)
StdDev: 0.3522174
Formula: ~1 | PointingTaskStartingLocations_Building %in% ID
(Intercept) Residual
StdDev: 0.3469856 1.28678
Fixed effects: log(AbsolutError_Building) ~ ContextEffectf + Agent_Action_levelf + ContextEffectf:Agent_Action_levelf
Value Std.Error DF
(Intercept) 3.429675 0.09606976 3324
ContextEffectfPublic -0.245529 0.05923021 3324
Agent_Action_levelfActive -0.222284 0.06103493 3324
ContextEffectfPublic:Agent_Action_levelfActive 0.219906 0.08637019 3324
t-value p-value
(Intercept) 35.69984 0.0000
ContextEffectfPublic -4.14533 0.0000
Agent_Action_levelfActive -3.64192 0.0003
ContextEffectfPublic:Agent_Action_levelfActive 2.54609 0.0109
Correlation:
(Intr) CntxEP Ag_A_A
ContextEffectfPublic -0.299
Agent_Action_levelfActive -0.289 0.472
ContextEffectfPublic:Agent_Action_levelfActive 0.205 -0.688 -0.709
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-6.0999775 -0.4666124 0.1969789 0.6806818 2.0367120
Number of Observations: 3803
Number of Groups:
ID
17
PointingTaskStartingLocations_Building %in% ID
476
Anova(TwofactorInteraction)Analysis of Deviance Table (Type II tests)
Response: log(AbsolutError_Building)
Chisq Df Pr(>Chisq)
ContextEffectf 10.8884 1 0.0009677 ***
Agent_Action_levelf 6.7910 1 0.0091617 **
ContextEffectf:Agent_Action_levelf 6.4894 1 0.0108520 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AgentPresence <-update(TwofactorInteraction, .~. + AgentPresencef)
summary(AgentPresence)Linear mixed-effects model fit by maximum likelihood
Data: df
AIC BIC logLik
12985.85 13035.79 -6484.923
Random effects:
Formula: ~1 | ID
(Intercept)
StdDev: 0.3522327
Formula: ~1 | PointingTaskStartingLocations_Building %in% ID
(Intercept) Residual
StdDev: 0.3469344 1.286775
Fixed effects: log(AbsolutError_Building) ~ ContextEffectf + Agent_Action_levelf + AgentPresencef + ContextEffectf:Agent_Action_levelf
Value Std.Error DF
(Intercept) 3.423574 0.09852252 3323
ContextEffectfPublic -0.245300 0.05924298 3323
Agent_Action_levelfActive -0.222299 0.06104241 3323
AgentPresencefDisplayed 0.012034 0.04296235 3323
ContextEffectfPublic:Agent_Action_levelfActive 0.219835 0.08638112 3323
t-value p-value
(Intercept) 34.74915 0.0000
ContextEffectfPublic -4.14058 0.0000
Agent_Action_levelfActive -3.64172 0.0003
AgentPresencefDisplayed 0.28011 0.7794
ContextEffectfPublic:Agent_Action_levelfActive 2.54494 0.0110
Correlation:
(Intr) CntxEP Ag_A_A AgntPD
ContextEffectfPublic -0.294
Agent_Action_levelfActive -0.282 0.472
AgentPresencefDisplayed -0.221 0.014 -0.001
ContextEffectfPublic:Agent_Action_levelfActive 0.201 -0.688 -0.709 -0.003
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-6.0949253 -0.4669407 0.1980209 0.6795859 2.0322987
Number of Observations: 3803
Number of Groups:
ID
17
PointingTaskStartingLocations_Building %in% ID
476
Anova(AgentPresence)Analysis of Deviance Table (Type II tests)
Response: log(AbsolutError_Building)
Chisq Df Pr(>Chisq)
ContextEffectf 10.8551 1 0.0009852 ***
Agent_Action_levelf 6.7974 1 0.0091292 **
AgentPresencef 0.0786 1 0.7792503
ContextEffectf:Agent_Action_levelf 6.4853 1 0.0108773 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Pairwiset<- emmeans(TwofactorInteraction, pairwise ~ ContextEffectf*Agent_Action_levelf, type='response')
Pairwiset $emmeans
ContextEffectf Agent_Action_levelf response SE df lower.CL upper.CL
Residential Passive 30.9 2.97 16 25.2 37.8
Public Passive 24.1 2.33 16 19.7 29.6
Residential Active 24.7 2.42 16 20.1 30.4
Public Active 24.1 2.34 16 19.6 29.6
Degrees-of-freedom method: containment
Confidence level used: 0.95
Intervals are back-transformed from the log scale
$contrasts
contrast ratio SE df null t.ratio
Residential Passive / Public Passive 1.278 0.0757 3324 1 4.145
Residential Passive / Residential Active 1.249 0.0762 3324 1 3.642
Residential Passive / Public Active 1.281 0.0768 3324 1 4.138
Public Passive / Residential Active 0.977 0.0604 3324 1 -0.376
Public Passive / Public Active 1.002 0.0610 3324 1 0.039
Residential Active / Public Active 1.026 0.0643 3324 1 0.409
p.value
0.0002
0.0016
0.0002
0.9819
1.0000
0.9770
Degrees-of-freedom method: containment
P value adjustment: tukey method for comparing a family of 4 estimates
Tests are performed on the log scale
ref_grid(TwofactorInteraction)'emmGrid' object with variables:
ContextEffectf = Residential, Public
Agent_Action_levelf = Passive, Active
Transformation: "log"
plot(Pairwiset[[2]])anova(interceptOnlyt, IDrandomInterceptOnlyt, StartlocationsrandomInterceptt) Model df AIC BIC logLik Test
interceptOnlyt 1 2 8619.140 8631.627 -4307.570
IDrandomInterceptOnlyt 2 3 7385.749 7404.479 -3689.874 1 vs 2
StartlocationsrandomInterceptt 3 5 8624.295 8655.512 -4307.147 2 vs 3
L.Ratio p-value
interceptOnlyt
IDrandomInterceptOnlyt 1235.391 <.0001
StartlocationsrandomInterceptt 1234.546 <.0001
HumanAf$Agent_Category <- with(HumanAf, ave(seq_along(ID), ID, FUN = function(x) sample(c(rep('Action', ceiling(length(x)*0.6)), rep('Standing', length(x) - ceiling(length(x)*0.6))))))